package com.keepsport.keepsportapi.controller;

import com.keepsport.keepsportapi.config.SystemConfig;
import com.keepsport.keepsportapi.dto.CommunityCircleAddDto;
import com.keepsport.keepsportapi.service.intf.CommunityCircleService;
import com.keepsport.keepsportapi.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/***
 *      ┌─┐       ┌─┐ + +
 *   ┌──┘ ┴───────┘ ┴──┐++
 *   │                 │
 *   │       ───       │++ + + +
 *   ███████───███████ │+
 *   │                 │+  
 *   │       ─┴─       │
 *   │                 │
 *   └───┐         ┌───┘
 *       │         │ 
 *       │         │   + +神兽保佑
 *       │         │      代码无BUG!
 *       │         └──────────────┐
 *       │                        │
 *       │                        ├─┐
 *       │                        ┌─┘
 *       │                        │
 *       └─┐  ┐  ┌───────┬──┐  ┌──┘  + + + +
 *         │ ─┤ ─┤       │ ─┤ ─┤
 *         └──┴──┘       └──┴──┘  + + + +
 *          Data:2022/7/1
 *          @author wyb
 *          Description
 */
@RestController
@RequestMapping("/api/circle")
@Api(tags = "关于朋友圈")
@CrossOrigin
public class CommunityCircleController {
    @Resource
    private CommunityCircleService service;

    @PostMapping("add.do")
    @ApiOperation(value = "发表朋友圈")
    public R add(@RequestBody CommunityCircleAddDto dto, HttpServletRequest request){
        //System.out.println(dto);
        return service.save(dto,request.getIntHeader(SystemConfig.TOKEN_HEADER));
    }

    @GetMapping("query.do")
    @ApiOperation(value = "查询所有朋友圈信息")
    public R query(){
        return service.query();
    }

    @GetMapping("selectLimit.do")
    @ApiOperation(value = "查询所有朋友圈信息")
    public R selectLimit(int page,int size){
        return service.selectLimit(page,size);
    }

    @GetMapping("queryMine.do")
    @ApiOperation(value = "查询自己的朋友圈")
    public R queryMine(HttpServletRequest request){
        return service.queryMine(request.getIntHeader(SystemConfig.TOKEN_HEADER));
    }

    @GetMapping("updatelikenum.do")
    @ApiOperation(value = "点赞")
    public R updateLikeNum(int id,HttpServletRequest request){
        return service.updataLikeNum(id,request.getIntHeader(SystemConfig.TOKEN_HEADER));
    }
    @GetMapping("queryOne.do")
    @ApiOperation(value = "查询指定消息id的消息内容")
    public R queryOne(HttpServletRequest request,int id){
        return service.queryOne(request.getIntHeader(SystemConfig.TOKEN_HEADER),id);
    }

}
